package team.sun.sss.dao.student;

import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;
import team.sun.sss.pojo.student.Family;
import team.sun.sss.pojo.student.StuFamily;

import java.util.List;

@Mapper
@Repository
public interface FamilyDao1 {

    //根据学号显示某个学生的所有家庭信息
    @Select("select * from family where stu_id=#{stuId}")
    List<Family> getFamilyList(int stuId);
    @Select("select * from family where stu_id=#{stuId}")
    Family familyInfo(int stuId);
    //根据序号显示详细信息
    @Select("select * from family where family_num=#{familyNum}")
    List<Family>familyFocusList(int familyNum);

    @Select("select family_relation from family where stu_id=#{stuId} and family_relation=#{familyRelation}")
    Family selectRelation(int stuId,String familyRelation);
    //2学生/学工处修改家庭信息
    @Update("update family set  family_relation=#{familyRelation},family_name=#{familyName},family_phone=#{familyPhone}," +
            "family_work_address=#{familyWorkAddress} where family_num=#{familyNum}")
    int updateFamily(StuFamily stuFamily);
    @Update("update family set  family_relation=#{familyRelation},family_name=#{familyName},family_phone=#{familyPhone}," +
            "family_work_address=#{familyWorkAddress} where family_num=#{familyNum}")
    int staffUpdateFamily(String familyRelation, String familyName,String familyPhone,String familyWorkAddress,int familyNum);
    //3.学生添加父母信息
    @Insert("insert into family(stu_id,family_relation,family_name,family_phone,family_work_address) values(#{stuId}," +
            "#{familyRelation},#{familyName},#{familyPhone},#{familyWorkAddress})")
    int addFamily(int stuId,String familyRelation,String familyName,String familyPhone,String familyWorkAddress);

    //4.学生删除某条家庭信息
    @Delete("delete from family where  family_num =#{familyNum}")
    int deleteFamily( int familyNum);
    //1申请表修改
    @Update("update family set  family_relation=#{familyRelation},family_name=#{familyName}," +
            "family_work_address=#{familyWorkAddress},family_work_type=#{familyWorkType},family_income=#{familyIncome}" +
            " where  family_num=#{familyNum}")
    int updateFamilyApply(String familyRelation, String familyName,String familyWorkAddress,
                          String familyWorkType,float familyIncome,int familyNum);
    //2申请表添加
    @Insert("insert into family(stu_id,family_relation,family_name,family_work_address,family_work_type,family_income) values(#{stuId}," +
            "#{familyRelation},#{familyName},#{familyWorkAddress},#{familyWorkType},#{familyIncome})")
    int addApplyFamily(int stuId,String familyRelation,String familyName,String familyWorkAddress,String familyWorkType,float familyIncome);


}
